<template>
	<view class="AnnuallyLogin">
		<u-navbar
			leftIconSize="35"
			:placeholder="false"
			bgColor="rgba(255,255,255,0)"
			@leftClick="leftClick"
			fixed
		></u-navbar>
		<view
			class="logo"
			style="width: 750rpx;margin: 0 auto;text-align: center;margin-top: 170rpx;display: flex;flex-direction: column;align-items: center;justify-content: center;"
		>
			<image :src="require('@/static/logo.jpg')" style="width: 135rpx;height: 148rpx;"></image>
			<view style="color: #333333;font-size: 50rpx;font-weight: 500;">年审人员登录</view>
		</view>

		<!-- 输入框 -->

		<!--  -->
		<view class="w-750 b-box" style="padding: 0 74rpx;margin-bottom: 60rpx;margin-top: 126rpx;">
			<view
				class="flex-c ali-i-s just-s"
				style="padding-bottom: 34rpx;margin-top: 44rpx;border-bottom: 2rpx solid #F1F1F1;"
			>
				<u-input
					border="none"
					placeholder="请输入账号"
					:customStyle="{ color: '#222222', font: '400 30rpx PingFang SC' }"
					placeholderStyle="color:#999999;fontWeight:400;fontsize:30px;fontfamily:PingFang SC-Regular, PingFang SC"
					v-model="requetParams.userName"
				></u-input>
			</view>
			<view
				class="flex-c ali-i-s just-s po-re"
				style="padding-bottom: 34rpx;margin-top: 44rpx;border-bottom: 2rpx solid #F1F1F1;"
			>
				<u-input
					border="none"
					placeholder="请输入密码"
					:password="showPwd"
					:customStyle="{
						boxSizing: 'border-box',
						paddingRight: '60rpx',
						color: '#333333',
						font: '400 30rpx PingFang SC'
					}"
					placeholderStyle="color:#999999;fontWeight:400;fontsize:30px;fontfamily:PingFang SC-Regular, PingFang SC"
					v-model="requetParams.userPwd"
				></u-input>
				<view class="po-ab" style="right: 0;top:5rpx">
					<image
						v-if="showPwd"
						@click="ShowPwd"
						:src="require('@/static/showpwd.png')"
						style="width: 40rpx;height: 24rpx;"
						mode=""
					></image>
					<image
						v-else
						@click="ShowPwd"
						:src="require('@/static/hidepwd.png')"
						style="width: 40rpx;height: 24rpx;"
						mode=""
					></image>
				</view>
			</view>

			<!-- btn -->
			<view style="margin: 0 auto;margin-top: 60rpx;">
				<button class="button" @click="login">登录</button>
			</view>

			<!-- btn -->
		</view>
	</view>
</template>

<script>
import { shlogin } from '@/common/api.js';
export default {
	data() {
		return {
			type: '',
			showPwd: true,
			requetParams: {
				userName: '',
				userPwd: ''
			}
		};
	},
	methods: {
		ShowPwd() {
			this.showPwd = !this.showPwd;
		},
		leftClick() {
			uni.navigateBack();
		},
		login() {
			if (this.requetParams.userName == '') {
				uni.showToast({
					title: '账号不能为空',
					icon: 'none'
				});
				return;
			}
			if (this.requetParams.userPwd == '') {
				uni.showToast({
					title: '密码不能为空',
					icon: 'none'
				});
				return;
			}
			let params = {
				account: this.requetParams.userName,
				password: this.requetParams.userPwd
			};
			shlogin(params).then(res => {
				console.log(res.data.data);
				if (res.data.code == 1) {
					uni.setStorageSync('AnnuallyUser', res.data.data);
					uni.showToast({
						title: res.data.msg
					});
					setTimeout(() => {
						uni.navigateTo({
							url: `/pages/AnnuallyIndex/AnnuallyIndex?type=${this.type}`
						});
						this.requetParams.userName = '';
						this.requetParams.userPwd = '';
					}, 1000);
				} else {
					uni.showToast({
						title: res.data.msg,
						icon: 'none'
					});
				}
			});
		}
	},
	onLoad(options) {
		this.type = options.type;
	}
};
</script>

<style lang="scss" scoped>
.button {
	width: 602rpx;
	height: 84rpx;
	line-height: 84rpx;
	color: #fff;
	text-align: center;
	background: linear-gradient(180deg, #4885c5 0%, #3b52a6 100%);
	border-radius: 100px 100px 100px 100px;
	opacity: 1;
}
</style>
